#encoding:UTF-8

#前台调用的时候记得只需要调用下划线之后的函数名
from xmlrpc import client
import pyjsonrpc
def xmlrpccall():
    '''
    xmlrpc客户端例子  记得启用相应的服务段
    :return:
    '''
    a=client.Server('http://localhost:7080')
    # print(a.add(3,4))
    print(a.addstr('adong','hello'))


def jsonrpccall():
    '''
    jsonrpc客户端例子  记得启动相应的服务端       少了一个包暂时不能用
    :return:
    '''

    http_client = pyjsonrpc.HttpClient(
        url="http://127.0.0.1",
        username="liuadong",
        password="nihao00o"
    )
    print(http_client.call("add", 1, 2))
    # Result: 3

    # It is also possible to use the *method* name as *attribute* name.
    print(http_client.add(1, 2))
    # Result: 3

    # Notifications send messages to the server, without response.
    http_client.notify("add", 3, 4)
if __name__=='__main__':
    jsonrpccall()

